
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>星际冒险家注册</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
    <style>
        .space-bg {
            background: url('https://picsum.photos/1600/900?grayscale&blur=2') center/cover no-repeat;
            background-color: #0f172a;
        }
        .card-glow {
            box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
        }
        .input-transition {
            transition: all 0.3s ease;
        }
        .input-transition:focus {
            transform: scale(1.02);
        }
    </style>
</head>
<body class="space-bg min-h-screen flex items-center justify-center p-4">
    <div class="w-full max-w-2xl">
        <div class="bg-gray-900 bg-opacity-80 rounded-xl shadow-xl overflow-hidden text-white card-glow">
            <div class="bg-gradient-to-r from-indigo-600 to-purple-600 py-5 px-6 flex items-center">
                <i class="fas fa-user-astronaut text-3xl mr-3"></i>
                <h1 class="text-2xl font-bold">星际冒险公民注册系统</h1>
            </div>
            
            <div class="p-6">
                <form id="userForm" class="space-y-6">
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label for="name" class="block text-sm font-medium mb-1">姓名</label>
                            <input type="text" id="name" name="name" required 
                                class="w-full px-4 py-2 rounded-lg bg-gray-800 border border-gray-700 input-transition focus:outline-none focus:ring-2 focus:ring-indigo-500">
                        </div>

                        <div>
                            <label class="block text-sm font-medium mb-1">性别</label>
                            <div class="flex space-x-4">
                                <label class="inline-flex items-center">
                                    <input type="radio" name="gender" value="male" class="h-4 w-4 text-indigo-600" checked>
                                    <span class="ml-2">男</span>
                                </label>
                                <label class="inline-flex items-center">
                                    <input type="radio" name="gender" value="female" class="h-4 w-4 text-indigo-600">
                                    <span class="ml-2">女</span>
                                </label>
                                <label class="inline-flex items-center">
                                    <input type="radio" name="gender" value="other" class="h-4 w-4 text-indigo-600">
                                    <span class="ml-2">其他</span>
                                </label>
                            </div>
                        </div>

                        <div>
                            <label for="phone" class="block text-sm font-medium mb-1">手机号</label>
                            <input type="tel" id="phone" name="phone" required 
                                class="w-full px-4 py-2 rounded-lg bg-gray-800 border border-gray-700 input-transition focus:outline-none focus:ring-2 focus:ring-indigo-500"
                                pattern="[0-9]{11}">
                            <p class="mt-1 text-xs text-gray-400">请输入11位手机号码</p>
                        </div>

                        <div>
                            <label for="idCard" class="block text-sm font-medium mb-1">身份证号</label>
                            <input type="text" id="idCard" name="idCard" required 
                                class="w-full px-4 py-2 rounded-lg bg-gray-800 border border-gray-700 input-transition focus:outline-none focus:ring-2 focus:ring-indigo-500"
                                pattern="[0-9]{17}[0-9Xx]">
                            <p class="mt-1 text-xs text-gray-400">请输入18位身份证号码</p>
                        </div>
                    </div>

                    <div>
                        <label for="address" class="block text-sm font-medium mb-1">家庭住址</label>
                        <textarea id="address" name="address" rows="3" required
                            class="w-full px-4 py-2 rounded-lg bg-gray-800 border border-gray-700 input-transition focus:outline-none focus:ring-2 focus:ring-indigo-500"></textarea>
                    </div>

                    <div class="flex items-center">
                        <input id="agree" name="agree" type="checkbox" required
                            class="h-4 w-4 text-indigo-600 rounded bg-gray-800 border-gray-700">
                        <label for="agree" class="ml-2 block text-sm">
                            我已阅读并同意<a href="#" class="text-indigo-400 hover:text-indigo-300">《星际冒险公民协议》</a>
                        </label>
                    </div>

                    <div class="pt-4">
                        <button type="submit" 
                            class="w-full bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-700 hover:to-purple-700 text-white font-bold py-3 px-4 rounded-lg transition duration-200 transform hover:scale-[1.02]">
                            成为星际冒险公民 <i class="fas fa-rocket ml-2"></i>
                        </button>
                    </div>
                </form>
            </div>
        </div>

        <div id="successModal" class="hidden fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center p-4 z-50">
            <div class="bg-gray-800 rounded-xl max-w-md w-full p-6 text-center border border-indigo-500">
                <div class="text-green-400 text-5xl mb-4 animate-bounce">
                    <i class="fas fa-check-circle"></i>
                </div>
                <h2 class="text-2xl font-bold text-white mb-2">注册成功！</h2>
                <p class="text-gray-300 mb-6">您已获得星际冒险公民身份，即将开始宇宙探索之旅！</p>
                <button onclick="closeModal()" 
                    class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-lg transition duration-200">
                    确认
                </button>
            </div>
        </div>
    </div>

    <script>
        document.getElementById('userForm').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const userData = {
                name: document.getElementById('name').value,
                gender: document.querySelector('input[name="gender"]:checked').value,
                phone: document.getElementById('phone').value,
                idCard: document.getElementById('idCard').value,
                address: document.getElementById('address').value,
                registerTime: new Date().toLocaleString()
            };

            // 保存到localStorage
            let users = JSON.parse(localStorage.getItem('spaceCitizens') || '[]');
            users.push(userData);
            localStorage.setItem('spaceCitizens', JSON.stringify(users));

            // 显示成功模态框
            document.getElementById('successModal').classList.remove('hidden');
            
            // 重置表单
            this.reset();
        });

        function closeModal() {
            document.getElementById('successModal').classList.add('hidden');
        }

        // 手机号输入验证
        document.getElementById('phone').addEventListener('input', function(e) {
            this.value = this.value.replace(/[^0-9]/g, '').slice(0, 11);
        });

        // 身份证号输入验证
        document.getElementById('idCard').addEventListener('input', function(e) {
            let val = this.value.replace(/[^0-9Xx]/g, '');
            if(val.length > 17) {
                val = val.slice(0, 17) + val[17].toUpperCase();
            }
            this.value = val.slice(0, 18);
        });
    </script>
</body>
</html>
